<?php
/**
 * 内部优惠券入口
 */

namespace App\Kuafu\Order\Controller\Pos;

use App\Kuafu\Base\Controller\BaseController;
use App\Kuafu\Coupon\Enum\CouponCodeEnum;
use App\Kuafu\Coupon\Service\CouponService;
use App\Kuafu\Coupon\Service\EnableCouponService;
use App\Kuafu\CustomerCoupon\Service\CustomerCouponService;
use App\Kuafu\Pay\Service\PayService;
use Illuminate\Http\JsonResponse;
use Illuminate\Http\Request;

class CouponController extends BaseController
{
    /**
     * 获取券码的券信息
     *
     * @param Request $request
     * @return JsonResponse
     */
    public function getCouponInfo(Request $request): JsonResponse
    {
        try {
            $couponCode = (string)$request->get('code');
            $returnData = (new CouponService(0, $this->shopId))->getKfCouponInfo($couponCode);
            return $this->success($returnData);
        } catch (\Exception $exception) {
            return $this->fail($exception->getCode(), $exception->getMessage());
        }
    }

}
